package com.jin.vo;

import com.jin.model.Activity;
import com.jin.model.Coupon;
import lombok.Getter;
import lombok.Setter;

import java.util.List;
import java.util.stream.Collectors;

@Getter
@Setter
//两级的属性精简
public class ActivityCouponVo extends ActivityPureVo {
    private List<CouponPureVo> coupons;

    public ActivityCouponVo(Activity activity) {
        super(activity);
        //把Coupon变成流传入到CouponPureVo里面，在对这个集合进行遍历（转成一个list）
        //把list<Coupon>变成了List<CouponPureVo>
        coupons=activity.getCouponList().stream().map(CouponPureVo::new).collect(Collectors.toList());
    }
}
